<template>
  <div class="app-container">
    <el-form ref="form" :model="order" label-width="120px">
<!--      <el-form-item label="流水">-->
<!--        <el-input v-model="order.id" />-->
<!--      </el-form-item>-->
      <el-form-item label="订单号">
        <el-input v-model="order.orderNum" />
      </el-form-item>
      <el-form-item label="用户名">
        <el-input v-model="order.name" />
      </el-form-item>


<!--      <el-form-item label="账单类目">-->
<!--        <el-input v-model="order.type" />-->
<!--      </el-form-item>-->


      <el-form-item label="账单类目">
        <el-select v-model="order.type" placeholder="请选择账单类目">
          <el-option label="物业费" value="1" />
          <el-option label="卫生费" value="2" />
          <el-option label="停车费" value="3" />
        </el-select>
      </el-form-item>


      <el-form-item label="支付方式">
        <el-input v-model="order.pay" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary"  @click="onSubmit">新增订单</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      order: {
        id: '',
        orderNum: '',
        name: '',
        type: '',
        pay: ''
      }
    }
  },
  methods: {
    onSubmit() {
      console.log(this.order.num)
      // 请求接口 实现用户新增接口的调用
      request({
        url:"http://127.0.0.1:8080/api/order/save.do",
        method: "POST",
        data:this.order
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/orderlist");
        }
      })
    },
    checkPass() {},
    onCancel() {
      this.$message({
        message: '取消订单的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

